package de.preamp.clients.java.lib.ui;

import java.awt.Dimension;
import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import de.preamp.clients.java.utils.ImageLoader;

/**
 * @author André Stannek
 * @version 2009-08-12
 */
public class StatusBar extends JPanel
{

    /**
     * generated UID.
     */
    private static final long serialVersionUID = -1996790734829944748L;

    /**
	 * 
	 */
    private final JLabel statusMessage;

    /**
	 * 
	 */
    private final JButton refreshButton;

    /**
	 * 
	 */
    private final JTextField filter;

    /**
     * default constructor.
     */
    public StatusBar()
    {
	super();
	statusMessage = new JLabel();
	refreshButton = new JButton();
	filter = new JTextField();

	this.initUI();
    }

    /**
     * initates the UI components.
     */
    private void initUI()
    {
	refreshButton.setIcon(new ImageIcon(ImageLoader
		.getImageURL("view-refresh.png")));
	this.setLayout(null);
	this.setSize(getWidth(), 32);
	this.setMinimumSize(new Dimension(100, 32));
	final Insets insets = this.getInsets();
	filter.setBounds(insets.left, insets.top, 200, 32);
	refreshButton.setBounds(insets.right - 32, insets.top, 32, 32);
	this.add(filter);
	this.add(refreshButton);
    }

    /**
     * Sets the status message displayed.
     * 
     * @param message
     *            the status message
     */
    public final void setStatusMessage(final String message)
    {
	statusMessage.setText(message);
    }

}
